package com.wnxy.sddfp.common.util;

import com.wnxy.sddfp.common.model.vo.user.TokenVo;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

public class TokenUtils {
    public static TokenVo getTokenVo(){
        ServletRequestAttributes requestAttributes =
                (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = requestAttributes.getRequest();
        // 从请求头中获取网关解析token后的用户信息
        String id = request.getHeader("id");
        String phone = request.getHeader("phone");

        TokenVo tokenVo = new TokenVo();
        tokenVo.setId(id);
        tokenVo.setPhone(phone);
        return tokenVo;
    }
}
